package com.wasu.entity.live;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * <p>------------------------------------------------------
 * <p>Copyright (C) 2020 wasu company, All rights reserved.
 * <p>------------------------------------------------------
 * <p> IP直播管理系统最外层请求结果解析
 * <p>
 *
 * @author Created by zhangmz
 * @date on 2023/8/1
 */
public class WasuBouChInfor implements Parcelable {

    /**
     * 返回结果：0-成功；1-失败
     */
    private String result;
    /**
     * 返回结果描述信息
     */
    private String resultDesc;
    /**
     * 版本号
     */
    private int version;

    /**
     * 频道组列表
     */
    private List<WasuBouInfor> bList;

    public WasuBouChInfor(){

    }

    public WasuBouChInfor(String result, String resultDesc, int version, List<WasuBouInfor> bList) {
        this.result = result;
        this.resultDesc = resultDesc;
        this.version = version;
        this.bList = bList;
    }

    protected WasuBouChInfor(Parcel in) {
        result = in.readString();
        resultDesc = in.readString();
        version = in.readInt();
        bList = in.createTypedArrayList(WasuBouInfor.CREATOR);
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(result);
        dest.writeString(resultDesc);
        dest.writeInt(version);
        dest.writeTypedList(bList);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<WasuBouChInfor> CREATOR = new Creator<WasuBouChInfor>() {
        @Override
        public WasuBouChInfor createFromParcel(Parcel in) {
            return new WasuBouChInfor(in);
        }

        @Override
        public WasuBouChInfor[] newArray(int size) {
            return new WasuBouChInfor[size];
        }
    };

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String getResultDesc() {
        return resultDesc;
    }

    public void setResultDesc(String resultDesc) {
        this.resultDesc = resultDesc;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public List<WasuBouInfor> getbList() {
        return bList;
    }

    public void setbList(List<WasuBouInfor> bList) {
        this.bList = bList;
    }

    public void addWasuBouInfor(WasuBouInfor wbi) {
        int index = 0;
        for (WasuBouInfor temp: bList) {
            if (wbi.getSortBy() < temp.getSortBy()) {
                bList.add(index, wbi);
                return;
            }
            index++;
        }
        bList.add(wbi);
    }

    @Override
    public String toString() {
        return "WasuBouChInfor{" +
                "result='" + result + '\'' +
                ", resultDesc='" + resultDesc + '\'' +
                ", version=" + version +
                ", bList=" + bList +
                '}';
    }
}
